package org.example.springyuanli.doms2.beanlife;

import lombok.extern.slf4j.Slf4j;
import org.example.springyuanli.demos.test.Dog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Slf4j
@RestController
public class TestBean {
    public TestBean() {
        log.info("执行实例化方法,..");
    }

    private Dog dog ;

    // 使用setter方便我们观察属性赋值
    @Autowired
    public void setDog(Dog dog) {
        this.dog = dog;
       log.info("执行setter方法 , 属性赋值...");
    }

    @PostConstruct
     public void init(){
        log.info("执行init 初始化方法 ...");
    }
    public void use(){
        log.info("执行user,使用Bean方法");
    }

    @PreDestroy
    public void destroy(){
        log.info("执行destroy销毁方法");
    }
}
